<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
  {:widget_st('jq','js')}
</head>
{:do_action('admin_head')}
<body>
  <style>
    @media screen and (min-width:1200px) {
      .list_item{
        width: 800px;
      }
    }
    .list_item>.layui-form-item:first-child{
      margin-bottom:0px;
    }
    .zf-layui-tips{
      border-bottom: 1px dashed #ccc;
    }
    .zf-tip-content-hidden{
      display: none;
    }
    .layui-input-block{
      min-height: 0px;
    }
  </style>
  <?php $form_widget = new \app\common\widget\FormPro();  ?>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
              <li class="layui-this">邮箱设置</li>
              <li >测试邮箱</li>
            </ul>
            <div class="layui-tab-content" style="height: 100%;">
              <div class="layui-tab-item layui-show">
                <form class="info_tj">
                	<?php if(!is_dir('./vendor/phpmailer/phpmailer')){ ?>
	                  <blockquote class="layui-elem-quote" style="text-align: center;">
	                    邮箱扩展(phpmailer/phpmailer)未安装,请先安装后使用
	                  </blockquote>
	                <?php } ?>
                  <div class="layui-form" wid100 lay-filter="">
                    <div  class="list_item" >
                      {$form_widget->form_input(['title'=>'<a class="zf-layui-tips">SMTP服务器</a>','name'=>'host','data'=>isset_arr_key($config,'host',''),'theme'=>2])|raw}
                      {$form_widget->form_note(['data'=>'<div class="zf-tip-content-hidden"><span class="layui-badge_  layui-bg-cyan_ ">ZFC("email_config.host") SMTP服务器  如：smtp.163.com</span></div>','theme'=>2])|raw}
                    </div>
                    <div  class="list_item" >
                      {$form_widget->form_input(['title'=>'<a class="zf-layui-tips">SMTP端口号</a>','name'=>'e_number','data'=>isset_arr_key($config,'e_number',''),'theme'=>2])|raw}
                      {$form_widget->form_note(['data'=>'<div class="zf-tip-content-hidden"><span class="layui-badge_  layui-bg-cyan_ ">ZFC("email_config.e_number") 一般为 25 或 465</span></div>','theme'=>2])|raw}
                    </div>
                   
                 
                 
                    <div class="layui-form-item">
                      <label class="layui-form-label">加密方式</label>
                      <div class="layui-input-inline" style="width: 80px;">
                        <select name="secure">
                          <option value="tls" <?php if(isset($config['secure'])&& $config['secure']=='tls'){ echo 'selected';} ?>>tls</option>
                          <option value="ssl" <?php if(isset($config['secure'])&& $config['secure']=='ssl'){ echo 'selected';} ?>>ssl</option>
                        </select>
                      </div>
                      <div class="layui-form-mid layui-word-aux"></div>
                    </div>
                 
                 
                
                  <div  class="list_item" >
                    {$form_widget->form_input(['title'=>'<a class="zf-layui-tips">发件人邮箱</a>','name'=>'send_email','data'=>isset_arr_key($config,'send_email',''),'theme'=>2])|raw}
                    {$form_widget->form_note(['data'=>'<div class="zf-tip-content-hidden"><span class="layui-badge_  layui-bg-cyan_ ">ZFC("email_config.send_email") 发件人邮箱</span></div>','theme'=>2])|raw}
                  </div>
                  <div  class="list_item" >
                    {$form_widget->form_input(['title'=>'<a class="zf-layui-tips">发件人昵称</a>','name'=>'send_nickname','data'=>isset_arr_key($config,'send_nickname',''),'theme'=>2])|raw}
                    {$form_widget->form_note(['data'=>'<div class="zf-tip-content-hidden"><span class="layui-badge_  layui-bg-cyan_ ">ZFC("email_config.send_nickname") 发件人昵称</span></div>','theme'=>2])|raw}
                  </div>
                  <div  class="list_item" >
                    {$form_widget->form_input(['title'=>'<a class="zf-layui-tips">邮箱密码/授权码</a>','name'=>'password','data'=>isset_arr_key($config,'password',''),'type'=>'password','theme'=>2])|raw}
                    {$form_widget->form_note(['data'=>'<div class="zf-tip-content-hidden"><span class="layui-badge_  layui-bg-cyan_ ">ZFC("email_config.password") 邮箱密码/授权码</span></div>','theme'=>2])|raw}
                  </div>
                  
                  <div class="layui-form-item">
                    <div class="layui-input-block">
                      <input type="button" value="确认保存" class="layui-btn layui-btn-sm"  onclick="tijiao_data2('config/email',0)">
                    </div>
                  </div>
                </div>
                </form>
              </div>
              <div class="layui-tab-item" >
                <div class="layui-form-item">
                  <label class="layui-form-label">测试邮箱</label>
                  <div class="layui-input-inline">
                    <input type="text" name="ee" value="" autocomplete="off" class="layui-input ee">
                  </div>
                  <div class="layui-form-mid layui-word-aux"><a href="javascript:;" class="layui-btn send_mail layui-btn-sm">发信测试</a></div>
                </div>
              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>

{:widget_st('layui','js')}
{:widget_st('common','js')}

<script>
  layui.define(['form', 'upload'], function(exports){
    var $ = layui.$
    ,layer = layui.layer
    ,laytpl = layui.laytpl
    ,setter = layui.setter
    ,view = layui.view
    ,admin = layui.admin
    ,form = layui.form
    ,upload = layui.upload;


    $('.zf-layui-tips').on('click', function(){
      var othis = $(this).parent().parent().parent().find('div:eq(2)').find('.layui-input-block .zf-tip-content-hidden').html()
      layer.tips(othis, this, {
        tips: 1,
        time: 8000
      });
    });

    $(".send_mail").on("click",function(){
      var ee = $('.ee').val();
      if(ee==''){
        layer.msg('请填写邮箱')
        return
      }
      var index = layer.load(2);
      $.ajax({
        type:'post',
        url:"{:url('config/test_email')}",
        data:{ee:ee},
        dataType:'json',
        success:function(res){
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
          }else{
            layer.msg(res.msg, {icon: 2});
          }
          layer.close(index)


        }
      })
    })
    window.tijiao_data2 = function(role,type=1){
      var index = layer.load(2);
      var data = $(".info_tj input,.info_tj select,.info_tj textarea,.info_tj option,.info_tj radio").serialize();      
          $.ajax({
            type:'post',
            url:'../'+role,
            data:data,
            dataType:'json',
            success:function(res){
              console.log(res)
              if(res.result==1){
                layer.msg(res.msg, {icon: 1});
                layer.close(index)
                setTimeout(function() {
                  if(type==1){
                  parent.location.reload();
                  }else{
                  // location.reload();
                  }
                }, 2000);
              }else{
                layer.msg(res.msg, {icon: 2});
                layer.close(index)
              }   
            }
          })
    }



  })
</script>
</body>
</html>
{:do_action('admin_js')}